package compare_array_overlap;

require Exporter;


our @ISA = qw(Exporter);
our $VERSION = 1.00;
our @EXPORT = qw(compare_array_overlap
SHARED		
OVERLAP		
ALL_2_IN_1	
ALL_1_IN_2	
     );

use strict;
use constant SHARED			=> 0;
use constant OVERLAP		=> 1;
use constant ALL_2_IN_1		=> 2;
use constant ALL_1_IN_2		=> 4;

#_________________________________________________________________________________________

#	compare_arrays_overlap


#		compare the overlap of arrays: are they supersets of each other or the same array

#_________________________________________________________________________________________
sub compare_array_overlap(\@\@)
{
	my ($arr1,  $arr2) = @_;
	my %all_items;
	@all_items{@$arr1} = ();
	@all_items{@$arr2} = ();
	my $cnt_both = scalar keys %all_items;
	if ($cnt_both == @$arr1)
	{
		if ($cnt_both == @$arr2)
		{
			# all items shared, which is why both array are equal
			return SHARED;
		}
		# all array2 are found in array 1 , which is why array size is equal to 1
		return ALL_2_IN_1;
	}
	elsif ($cnt_both == @$arr2)
	{
		# all array1 are found in array 2 , which is why array size is equal to 2
		return ALL_1_IN_2;
	}
	return OVERLAP;
}


